<?php defined('BASEPATH') OR exit('No direct script access allowed');

class admin extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		
		if (!$this->ion_auth->logged_in())
		{
			//redirect them to the login page
			redirect('auth/login', 'refresh');
		}
		elseif (!$this->ion_auth->is_admin())
		{
			//redirect them to the home page because they must be an administrator to view this	
			redirect('/', 'refresh');
		}
		$this->load->model('case_model');
        $this->load->library('datatables');			
	}

	//redirect if needed, otherwise display the user list
	function index()
	{
	     $data['country']=$this->case_model->get_country();
		 $data['engineer']=$this->case_model->get_engineer();
		 $data['max_id']=$this->case_model->get_id()->row();
		 $meta['page_title'] = 'Call Cordinator Dashboard';
		 $this->load->view('common/header',$meta);
	     $this->load->view('user/case',$data);
		 $this->load->view('common/footer');		
	}
	public function create_customer()
	{ 
	    $data['engineer']=$this->case_model->get_engineer();
	    $this->load->library('form_validation');
	    $this->form_validation->set_rules('company_name', 'Company Name', 'required');
		$this->form_validation->set_rules('contact_person', 'Contact Person', 'required');
		$this->form_validation->set_rules('address', 'Address', 'required');
		$this->form_validation->set_rules('pin_code', 'Pin Code', 'required|numeric|min_length[6]|max_length[6]');
		$this->form_validation->set_rules('landline_no', 'Landline No.', 'required|numeric|min_length[10]|max_length[12]');
		$this->form_validation->set_rules('mobile_no', 'Mobile No.', 'required|numeric|min_length[10]|max_length[12]');
		$this->form_validation->set_rules('email_id', 'Email-ID', 'required|valid_email');
		$this->form_validation->set_rules('model_no', 'Model No.', 'required');
		$this->form_validation->set_rules('product_no', 'Product No.', 'required');
		$this->form_validation->set_rules('serial_no', 'Serial No.', 'required');
		$this->form_validation->set_rules('password', 'Password', 'required');
		$this->form_validation->set_rules('operating_system', 'Operating System', 'required');
		$this->form_validation->set_rules('country_purchase', 'Country Of Purchase', 'required');
		$this->form_validation->set_rules('issue_reported', 'Issue Reported' );
		$this->form_validation->set_rules('demo_diagnosis', 'Demo Diagnosis');
			if ($this->form_validation->run() == true)
            {	
           $engineer_ids=$_REQUEST['id_engineer'];
           if( !empty($engineer_ids))
          {
              $engineer_ids=$_REQUEST['id_engineer'];
			 }else{
			 $engineer_ids=$this->session->userdata['user_id'];
			 
			 }
		   
		 $insert = array(
	        'service_id'            =>$this->input->post('service_id'),
			'company_name'   =>$this->input->post('company_name'),
			'customer_name'      =>$this->input->post('contact_person'),
			'customer_address'   =>$this->input->post('address'),
			'pincode'   =>$this->input->post('pin_code'),
			'landline'  =>$this->input->post('landline_no'),
			'mobile'    =>$this->input->post('mobile_no'),
			'email'     =>$this->input->post('email_id'),
			'model_no'           =>$this->input->post('model_no'),
		    'product_no'         =>$this->input->post('product_no'),
		    'serial_no'          =>$this->input->post('serial_no'),
		    'password'  =>$this->input->post('password'),
		    'operating_system'         =>$this->input->post('operating_system'),
		    'country_purchase'   =>$this->input->post('country_purchase'),
	        'issue_reported'     =>$this->input->post('issue_reported'),
	        'engineer_diagnosis' =>$this->input->post('demo_diagnosis'),
			'engineer_id'      =>$engineer_ids,
			'service_date'     =>$this->input->post('datepicker')
			
			);
	
			$latest_id=$this->case_model->create_service($insert);
			$accesories= array(
			'customer_id'        =>$latest_id,
	        'ac_adapter'         =>$this->input->post('chk_adapter'),
	        'driver_cd'           =>$this->input->post('chk_driver'),
	        'bag'                 => $this->input->post('chk_bag'),
		    'hdd'                 => $this->input->post('chk_hdd'),
		    'power_cord'          => $this->input->post('chk_powercord'),
			'carry_casebelt'            => $this->input->post('chk_carry'),
			'optical_drive'        => $this->input->post('chk_optical'),
			'modem_card'           =>$this->input->post('chk_fax'),
			'network_card'          =>$this->input->post('chk_network'),
			'memory'                =>$this->input->post('chk_memory'),
			'capacity'               =>$this->input->post('chk_capacity'),
			'tray'                   =>$this->input->post('chk_tray'),
			'battry'             =>$this->input->post('chk_battery'),
			 'cradle'                =>$this->input->post('chk_cradle'),
			 'fdd'                    =>$this->input->post('chk_fdd'),
			'itb'                      =>$this->input->post('chk_itb'),
		    'wireless'             =>$this->input->post('chk_wireless'),
			 'comment_scratches'    =>$this->input->post('scratches'),
			 'comment_damages'       =>$this->input->post('damage'),
			 'comment_other'          =>$this->input->post('other'),
			 
			 'ac_adapter_detail'          => $this->input->post('adapter'),
			'driver_cd_detail'            => $this->input->post('drivercd'),
			'bag_detail'               => $this->input->post('bag'),
			'hdd_detail'               =>$this->input->post('hdd'),
			'power_cord_detail'          =>$this->input->post('powerCord'),
			'carry_casebelt_detail'          =>$this->input->post('carryCase'),
			'optical_drive_detail'            =>$this->input->post('opticalDrive'),
			'modem_card_detail'              =>$this->input->post('faxModem'),
			'network_card_detail'             =>$this->input->post('networkCard'),
			 'memory_detail'              =>$this->input->post('memory'),
			 'capacity_detail'            =>$this->input->post('capacity'),
			'tray_detail'                 =>$this->input->post('tray'),
		    'battry_serial'             =>$this->input->post('battery'),
			 'cradle_detail'             =>$this->input->post('cradle'),
			 'fdd_detail'    =>$this->input->post('fdd'),
			 'itb_detail'       =>$this->input->post('itb'),
			 'wireless_detail'          =>$this->input->post('wireless'),
			
			);
	
	        $this->case_model->create_accesories($accesories);
		  	if($_REQUEST['warranty']==1)
			{
			$max_case['id']=$this->case_model->get_caseid()->row();
			$service_id=$this->input->post('service_id');
			$service= $max_case['id']->id+1;
			$date=date('M');
			$date=$date.'/';
		    $newcase=strtoupper('CASE/'.$date.$service);
			$case=array('service_id'=>$service_id,'case_no'=>$newcase,'status_id'=>1,'engineer_id'=>$engineer_ids,'date'=>$this->input->post('datepicker'),);
			 $case_id=$this->case_model->create_case($case);
		
			 $diagnos=array(
			  'service_id'            =>$this->input->post('service_id'),
			'enginer_id'      =>$engineer_ids,
			'status_id'           =>1,
			'date'                 =>$this->input->post('datepicker'),
			'case_id'             =>$case_id,
			);
			 $diagnosis=$this->case_model->create_diagnosis($diagnos);
			 } else
			 { 
			 $max_case['id']=$this->case_model->nonwarranty_caseid()->row();
			$service_id=$this->input->post('service_id');
			$service= $max_case['id']->id+1;
			$date=date('M');
			$date=$date.'/';
		    $newcase=strtoupper('CASE/N/'.$date.$service);
			$case=array('service_id'=>$service_id,'case_no'=>$newcase,'status_id'=>1,'engineer_id'=>$engineer_ids,'date'=>$this->input->post('datepicker'),);
			 $case_id=$this->case_model->nonwarranty_case($case);
		
			 $diagnos=array(
			  'service_id'            =>$this->input->post('service_id'),
			'engineer_id'      =>$engineer_ids,
			'status_id'           =>1,
			'date'                 =>$this->input->post('datepicker'),
			'case_id'             =>$case_id,
			);
			 $diagnosis=$this->case_model->nonwarranty_diagnosis($diagnos);
			 }
		    redirect('admin/list_view');
		   }
		   else
		   {
		    $data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
			
		   $meta['page_title'] = 'Admin Dashboard';
		    $data['country']=$this->case_model->get_country();
		   $data['max_id']=$this->case_model->get_id()->row();
		  
		   $this->load->view('common/header',$meta);
		   $this->load->view('user/case',$data );
		   $this->load->view('common/footer');	
			
		   } 
		   }
        function list_view()
		{
		 $meta['page_title'] = 'Admin List View';
		 $this->load->view('common/header',$meta);
		 $this->load->view('user/list_view');
		 $this->load->view('common/footer');		
		
		}
		function get()
		{
		echo $this->case_model->get_view();
		
		}
		function nonwarranty_get()
		{
		echo $this->case_model->get_nonwarrantyview();
		
		}
		function edit_customer($id)
		{
		  $this->load->library('form_validation');
		 $meta['page_title'] = "Edit Customer";
		 $user = $this->case_model->edit_case($id)->row();
		 $access=$this->case_model->edit_access($id)->row();
		 //print_r($case);exit;
		 $this->data['case'] = $user;
		 //$dat =$this->case_model->get_country();
		 //$this->data['country']=$dat;
		$this->form_validation->set_rules('customer_company', 'Company Name', 'required');
		$this->form_validation->set_rules('customer_name', 'Contact Person', 'required');
		$this->form_validation->set_rules('customer_address', 'Address', 'required');
		$this->form_validation->set_rules('customer_pincode', 'Pin Code', 'required|numeric|min_length[5]|max_length[10]');
		$this->form_validation->set_rules('customer_landline', 'Landline No.', 'required|numeric|min_length[7]|max_length[12]');
		$this->form_validation->set_rules('customer_mobile', 'Mobile No.', 'required|numeric|min_length[10]|max_length[12]');
		$this->form_validation->set_rules('customer_email', 'Email-ID', 'required|valid_email');
		$this->form_validation->set_rules('model_no', 'Model No.', 'required');
		$this->form_validation->set_rules('product_no', 'Product No.', 'required');
		$this->form_validation->set_rules('serial_no', 'Serial No.', 'required');
		$this->form_validation->set_rules('customer_password', 'Password', 'required');
		$this->form_validation->set_rules('customer_os', 'Operating System', 'required');
		$this->form_validation->set_rules('country_purchase', 'Country Of Purchase', 'required');
		$this->form_validation->set_rules('issue_reported', 'Issue Reported', 'required');
		$this->form_validation->set_rules('enginer_diagnosis', 'Demo Diagnosis', 'required');
		 if (isset($_POST) && !empty($_POST))
		{ 
		 $insert = array(
	        'service_id'            =>$user->service_id,
			'company_name'   =>$this->input->post('customer_company'),
			'customer_name'      =>$this->input->post('customer_name'),
			'customer_address'   =>$this->input->post('customer_address'),
			'pincode'   =>$this->input->post('customer_pincode'),
			'landline'  =>$this->input->post('customer_landline'),
			'mobile'    =>$this->input->post('customer_mobile'),
			'email'     =>$this->input->post('customer_email'),
			'model_no'           =>$this->input->post('model_no'),
		    'product_no'         =>$this->input->post('product_no'),
		    'serial_no'          =>$this->input->post('serial_no'),
		    'password'  =>$this->input->post('customer_password'),
		    'operating_system'         =>$this->input->post('customer_os'),
		    'country_purchase'   =>$this->input->post('country_purchase'),
	        'issue_reported'     =>$this->input->post('issue_reported'),
	        'engineer_diagnosis' =>$this->input->post('enginer_diagnosis'),
	       
			
			   
			   
			   );
			   
			   
			   $accesories=array(
			 'ac_adapter_detail'          => $this->input->post('adapter'),
			'driver_cd_detail'            => $this->input->post('drivercd'),
			'bag_detail'               => $this->input->post('bag'),
			'hdd_detail'               =>$this->input->post('hdd'),
			'power_cord_detail'          =>$this->input->post('powerCord'),
			'carry_casebelt_detail'          =>$this->input->post('carryCase'),
			'optical_drive_detail'            =>$this->input->post('opticalDrive'),
			'modem_card_detail'              =>$this->input->post('faxModem'),
			'network_card_detail'             =>$this->input->post('networkCard'),
			 'memory_detail'              =>$this->input->post('memory'),
			 'capacity_detail'            =>$this->input->post('capacity'),
			'tray_detail'                 =>$this->input->post('tray'),
		    'battry_serial'             =>$this->input->post('battery'),
			 'cradle_detail'             =>$this->input->post('cradle'),
			 'fdd_detail'    =>$this->input->post('fdd'),
			 'itb_detail'       =>$this->input->post('itb'),
			 'wireless_detail'          =>$this->input->post('wireless'),
			  'ac_adapter'         =>$this->input->post('ac_adapter'),
	        'driver_cd'           =>$this->input->post('driver_cd'),
	        'bag'                 => $this->input->post('cus_bag'),
		    'hdd'                 => $this->input->post('cus_hdd'),
		    'power_cord'          => $this->input->post('power_cord'),
			'carry_casebelt'           => $this->input->post('cus_carrycase'),
			'optical_drive'       => $this->input->post('optical_drive'),
			'modem_card'          =>$this->input->post('modem_card'),
			'network_card'        =>$this->input->post('network_card'),
			'memory'              =>$this->input->post('cus_memory'),
			'capacity'            =>$this->input->post('cus_capacity'),
			'tray'                =>$this->input->post('cus_tray'),
			'battry'          =>$this->input->post('battery_no'),
			 'cradle'             =>$this->input->post('cus_cradle'),
			 'fdd'                 =>$this->input->post('cus_fdd'),
			'itb'                  =>$this->input->post('cus_itb'),
		    'wireless'         =>$this->input->post('wireless_lan'),
			 'comment_scratches'   =>$this->input->post('scratches'),
			  'comment_damages'    =>$this->input->post('damages'),
			  'comment_other'     =>$this->input->post('other'),
			);
			
			if ($this->form_validation->run() === TRUE)
			{
				$this->case_model->update($user->id, $insert);
				$this->case_model->update_acces($access->id,$accesories);
				redirect("admin/list_view");
				
			}
			
			
		 }
		  $this->data['case_id'] = array(
			'name'  => 'case',
			'id'    => 'case_id',
			'type'  => 'text',
			'class' => 'span4',
			'readonly'  =>true,
			'value' => $this->form_validation->set_value('case_id', $user->service_id),
		);
		 $this->data['adapter_detail'] = array(
			'name'  => 'adapter',
			'id'    => 'adapter',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('adapter_detail', $access->ac_adapter_detail),
		);
		$this->data['driver_detail'] = array(
			'name'  => 'drivercd',
			'id'    => 'drivercd',
			'type'  => 'text',
				'class'  =>'span12',
			'value' => $this->form_validation->set_value('driver_detail', $access->driver_cd_detail),
		);
		 $this->data['bag_detail'] = array(
			'name'  => 'bag',
			'id'    => 'bag',
			'type'  => 'text',
				'class'  =>'span12',
			'value' => $this->form_validation->set_value('bag_detail', $access->bag_detail),
		);
		 $this->data['hdd_detail'] = array(
			'name'  => 'hdd',
			'id'    => 'hdd',
			'type'  => 'text',
				'class'  =>'span12',
			'value' => $this->form_validation->set_value('hdd_detail', $access->hdd_detail),
		);
		 $this->data['powercord_detail'] = array(
			'name'  => 'powerCord',
			'id'    => 'power_cordt',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('powercord_detail', $access->power_cord_detail),
		);
		 $this->data['carrycase_detail'] = array(
			'name'  => 'carryCace',
			'id'    => 'carry_case',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('carrycase_detail', $access->carry_casebelt_detail),
		);
		 $this->data['optical_detail'] = array(
			'name'  => 'opticalDrive',
			'id'    => 'optical_drivet',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('optical_detail', $access->optical_drive_detail),
		);
		 $this->data['modem_detail'] = array(
			'name'  => 'faxModem',
			'id'    => 'fax_modem',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('modem_detail', $access->modem_card_detail),
		);
		 $this->data['network_detail'] = array(
			'name'  => 'networkCard',
			'id'    => 'network_cardt',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('network_detail', $access->network_card_detail),
		);
		 $this->data['memory_detail'] = array(
			'name'  => 'memory',
			'id'    => 'memory',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('memory_detail', $access->memory_detail),
		);
		 $this->data['capacity_detail'] = array(
			'name'  => 'capacity',
			'id'    => 'capacity',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('capacity_detail', $access->capacity_detail),
		);
		 $this->data['tray_detail'] = array(
			'name'  => 'tray',
			'id'    => 'tray',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('tray_detail', $access->tray_detail),
		);
		 $this->data['battery_detail'] = array(
			'name'  => 'battery',
			'id'    => 'battery',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('battery_detail', $access->battry_serial),
		);
		 $this->data['cradle_detail'] = array(
			'name'  => 'cradle',
			'id'    => 'cradle',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('cradle_detail', $access->cradle_detail),
		);
		 $this->data['fdd_detail'] = array(
			'name'  => 'fdd',
			'id'    => 'fdd',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('fdd_detail', $access->fdd_detail),
		);
		 $this->data['itb_detail'] = array(
			'name'  => 'itb',
			'id'    => 'itb',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('itb_detail', $access->itb_detail),
		);
		 $this->data['wireless_detail'] = array(
			'name'  => 'wireless',
			'id'    => 'wireless',
			'type'  => 'text',
			'class'  =>'span12',
			'value' => $this->form_validation->set_value('wireless_detail', $access->wireless_detail),
		);
		
		
		
		$this->data['case_date'] = array(
			'name'  => 'date',
			'id'    => 'date',
			'type'  => 'text',
			'class' =>'span7',
			'value' => $this->form_validation->set_value('case_date', $user->service_date),
		);
		$this->data['customer_company'] = array(
			'name'  => 'customer_company',
			'id'    => 'customer_company',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_company', $user->company_name),
		);
		$this->data['customer_name'] = array(
			'name'  => 'customer_name',
			'id'    => 'customer_name',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_name', $user->customer_name),
		);
		$this->data['customer_address'] = array(
			'name'  => 'customer_address',
			'id'    => 'customer_address',
			'rows' =>'5',
			'type'  => 'textarea',
			'value' => $this->form_validation->set_value('customer_address', $user->customer_address),
		);
		$this->data['customer_pincode'] = array(
			'name'  => 'customer_pincode',
			'id'    => 'customer_pincode',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_pincode', $user->pincode),
		);
		$this->data['customer_landline'] = array(
			'name'  => 'customer_landline',
			'id'    => 'customer_landline',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_landline', $user->landline),
		);$this->data['customer_mobile'] = array(
			'name'  => 'customer_mobile',
			'id'    => 'customer_mobile',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_mobile', $user->mobile),
		);
		$this->data['customer_email'] = array(
			'name'  => 'customer_email',
			'id'    => 'customer_email',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_email', $user->email),
		);
		$this->data['model_no'] = array(
			'name'  => 'model_no',
			'id'    => 'model_no',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('model_no', $user->model_no),
		);
		$this->data['product_no'] = array(
			'name'  => 'product_no',
			'id'    => 'product_no',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('product_no', $user->product_no),
		);
		$this->data['serial_no'] = array(
			'name'  => 'serial_no',
			'id'    => 'serial_no',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('serial_no', $user->serial_no),
		);
		$this->data['customer_password'] = array(
			'name'  => 'customer_password',
			'id'    => 'customer_password',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_password', $user->password),
		);
		$this->data['customer_os'] = array(
			'name'  => 'customer_os',
			'id'    => 'customer_os',
			'type'  => 'text',
			'value' => $this->form_validation->set_value('customer_os', $user->operating_system),
		);
	
		$this->data['country_purch'] =$this->case_model->get_country();
			
		$this->data['country_purchase'] = array(
			'name'  => 'country_purchase',
			'id'    => 'country_purchase',
			'type'  => 'select',
			'value' => $this->form_validation->set_value('country_purchase', $user->country_purchase),
		);
		
		$this->data['issue_reported'] = array(
			'name'  => 'issue_reported',
			'id'    => 'issue_reported',
			'type'  => 'textarea',
			'rows' =>'5',
			'value' => $this->form_validation->set_value('issue_reported', $user->issue_reported),
		);
		$this->data['enginer_diagnosis'] = array(
			'name'  => 'enginer_diagnosis',
			'id'    => 'enginer_diagnosis',
			'rows' =>'5',
			'type'  => 'textarea',
			'value' => $this->form_validation->set_value('enginer_diagnosis', $user->engineer_diagnosis),
		);
		$this->data['ac_adapter'] = array(
			'name'  => 'ac_adapter',
			'id'    => 'ac_adapter',
			'checked' =>$access->ac_adapter,
            'value'=>$this->form_validation->set_value('ac_adapter', 1),
		);
		$this->data['driver_cd'] = array(
			'name'  => 'driver_cd',
			'id'    => 'driver_cd',
			'checked' => $access->driver_cd,
			'value'=>$this->form_validation->set_value('driver_cd', 1),
		);
		$this->data['bag'] = array(
			'name'  => 'cus_bag',
			'id'    => 'cus_bag',
			'checked' => $access->bag,
			'value' => $this->form_validation->set_value('cus_bag', 1),
			
		);
			$this->data['hdd'] = array(
			'name'  => 'cus_hdd',
			'id'    => 'cus_hdd',
			'checked' =>$access->hdd,
			'value' => $this->form_validation->set_value('cus_hdd', 1),
		);
			$this->data['power_cord'] = array(
			'name'  => 'power_cord',
			'id'    => 'power_cord',
			'checked' =>$access->power_cord,
			'value' => $this->form_validation->set_value('power_cord',1),
		);
			$this->data['carrycase'] = array(
			'name'  => 'cus_carrycase',
			'id'    => 'cus_carrycase',
			'checked' =>$access->carry_casebelt,
			'value' => $this->form_validation->set_value('cus_carrycase', 1),
		);
			$this->data['optical_drive'] = array(
			'name'  => 'optical_drive',
			'id'    => 'optical_drive',
			'checked' =>$access->optical_drive,
			'value' => $this->form_validation->set_value('optical_drive', 1),
		);
			$this->data['modem_card'] = array(
			'name'  => 'modem_card',
			'id'    => 'modem_card',
			'checked' => $access->modem_card,
			'value' =>$this->form_validation->set_value('modem_card', 1),
		);
			$this->data['network_card'] = array(
			'name'  => 'network_card',
			'id'    => 'network_card',
			'checked' =>$access->network_card,
			'value' => $this->form_validation->set_value('network_card', 1),
		);
			$this->data['memory'] = array(
			'name'  => 'cus_memory',
			'id'    => 'cus_memory',
			'checked' =>$access->memory,
			'value' => $this->form_validation->set_value('cus_memory', 1),
		);
			$this->data['capacity'] = array(
			'name'  => 'cus_capacity',
			'id'    => 'cus_capacity',
			'checked' =>$access->capacity,
			'value' => $this->form_validation->set_value('cus_capacity', 1),
		);
			$this->data['tray'] = array(
			'name'  => 'cus_tray',
			'id'    => 'cus_tray',
			'checked' =>$access->tray,
			'value' => $this->form_validation->set_value('cus_tray', 1),
		);
			$this->data['battery_no'] = array(
			'name'  => 'battery_no',
			'id'    => 'battery_no',
			'checked' =>$access->battry,
			'value' => $this->form_validation->set_value('battery_no', 1),
		);
			$this->data['cradle'] = array(
			'name'  => 'cus_cradle',
			'id'    => 'cus_cradle',
			'checked' =>$access->cradle,
			'value' => $this->form_validation->set_value('cus_cradle', 1),
		);
			$this->data['fdd'] = array(
			'name'  => 'cus_fdd',
			'id'    => 'cus_fdd',
			'checked' =>$access->fdd,
			'value' => $this->form_validation->set_value('cus_fdd', 1),
		);
			$this->data['itb'] = array(
			'name'  => 'cus_itb',
			'id'    => 'cus_itb',
			'checked' =>$access->itb,
			'value' => $this->form_validation->set_value('cus_itb', 1),
		);
			$this->data['wireless_lan'] = array(
			'name'  => 'wireless_lan',
			'id'    => 'wireless_lan',
			'checked' =>$access->wireless,
			'value' => $this->form_validation->set_value('wireless_lan', 1),
		);
		$this->data['comment_scratches'] = array(
			'name'  => 'scratches',
			'id'    => 'scratches',
			'rows' =>'5',
			'type'  => 'textarea',
			'value' => $this->form_validation->set_value('comment_scratches', $access->comment_scratches),
		);
		$this->data['comment_damages'] = array(
			'name'  => 'damages',
			'id'    => 'damages',
			'rows' =>'5',
			'type'  => 'textarea',
			'value' => $this->form_validation->set_value('comment_damages', $access->comment_damages),
		);
		$this->data['comment_other'] = array(
			'name'  => 'other',
			'id'    => 'other',
			'type'  => 'textarea',
			'rows' =>'5',
			'value' => $this->form_validation->set_value('comment_other', $access->comment_other),
		);
		$this->data['submit'] = array(
			'name' => 'submit',
			'id'   => 'submit',
			'type' => 'submit',
			'value' =>'Save',
			'class' =>'btn btn-success'
		);
		$this->data['purchase_country']=$user->country_purchase;
		 //$dat['country']=$this->case_model->get_country();
		 $this->load->view('common/header',$meta);
		 $this->load->view('user/edit_view',$this->data);
		 $this->load->view('common/footer');	
		
		}
		function delete_customer($id)
		{
		$this->case_model->delete_case($id);
		redirect("admin/list_view");	
		}
		 function print_case($id)
       {
	 
	   $meta['page_title'] = 'Print';
	   $data['company_profile']=$this->case_model->company_profile()->row();
       $data['case_detail']= $this->case_model->get_casedetail($id);
	   $data['case_no']=$this->case_model->get_case_no($id)->row();
	 
	   $data['so']=$this->case_model->get_so_detail($data['case_no']->id);
	
       $data['access']=$this->case_model->get_accesoriesdetail($id);   
	   $this->load->view('common/header',$meta);
	   $this->load->view('user/print_view',$data);
	   $this->load->view('common/footer');
	   }
	function print_nonwarranty_case($id)
       {
	   $meta['page_title'] = 'Print';
	   $data['company_profile']=$this->case_model->company_profile()->row();
       $data['case_detail']= $this->case_model->get_casedetail($id);
	   $data['case_no']=$this->case_model->get_nonwarrantycase_no($id)->row();
       $data['access']=$this->case_model->get_accesoriesdetail($id);   
	   $this->load->view('common/header',$meta);
	   $this->load->view('user/print_view',$data);
	   $this->load->view('common/footer');
	   }




		
}
